/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.            */
/*                                                                 */
/*  NAME      = t__sqlserver_add_metadata.c                        */
/*  NOTE      =                                                    */
/*  DATE      = 2014/12/10 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <CUnit/Basic.h>

#include <frcomm.h>
#include <sqlserver/config.h>
#include <sqlserver/sqlserver_core.h>

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

extern int __sqlserver_add_metadata(unsigned char uc_tds_data_type, unsigned int ui_precision, unsigned int ui_scale,
                                    int i_plp_flg, Frlist_header *p_lst_header);

static void __case1(void)
{
    int i_ret = 0;
    unsigned char uc_tds_data_type = 1;
    unsigned int ui_precision = 1;
    unsigned int ui_scale = 1;
    int i_plp_flg = 1;
    Frlist_header *p_lst_header = frlist_create();

    i_ret = __sqlserver_add_metadata(uc_tds_data_type, ui_precision, ui_scale, i_plp_flg, p_lst_header);

    CU_ASSERT_EQUAL(i_ret, FR_SUCC);

    frlist_remove_all(p_lst_header, frdb_metadata_node_free);
    frfree(p_lst_header);

    return;
}

int add_suite__sqlserver_add_metadata(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" __sqlserver_add_metadata()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    //增加测试用例
    if (CU_add_test(pSuite, "case1", __case1) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
